<?php

namespace Common\Models\Users;

use Phalcon\Mvc\Model\Validator\Uniqueness;
use Phalcon\Mvc\Model;

class PermissionResource extends Model
{
    /**
     *
     * @var integer
     */
    protected $id;

    /**
     *
     * @var string
     */
    protected $name;

    /**
     *
     * @var string
     */
    protected $value;

    /**
     *
     * @var integer
     */
    protected $status;

    /**
     * Method to set the value of field id
     *
     * @param integer $id
     * @return $this
     */
    public function setId($id)
    {
        $this->id = $id;

        return $this;
    }

    /**
     * Method to set the value of field name
     *
     * @param string $name
     * @return $this
     */
    public function setName($name)
    {
        $this->name = $name;

        return $this;
    }

    /**
     * Returns the value of field id
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Returns the value of field name
     *
     * @return string
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * @param string $value
     */
    public function setValue($value)
    {
        $this->value = $value;
    }

    /**
     * @return string
     */
    public function getValue()
    {
        return $this->value;
    }



    /**
     * @param int $status
     */
    public function setStatus($status)
    {
        $this->status = $status;
    }

    /**
     * @return int
     */
    public function getStatus()
    {
        return $this->status;
    }



    public function getSource()
    {
        return 'permission_resource';
    }

    public function validation()
    {
        $this->validate(new Uniqueness(array(
            'field' => 'name',
            'message'   => 'name already registered'
        )));

        $this->validate(new Uniqueness(array(
            'field' => 'value',
            'message'   => 'value already registered'
        )));

        return $this->validationHasFailed() != true;
    }

    public function initialize()
    {

    }
} 